package site;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletResponse;

public class UpdateRequest extends ProcessRequest{


    private String rArcVersion;

    
    public UpdateRequest(ServletContext context){
        rArcVersion = context.getInitParameter("rArcVersion");
    }


    @Override
    protected  void process(HttpServletResponse response, String[] arguments) {

        response.setContentType("text/plain; charset=UTF-8");


       String rArcClientVersion = arguments[0];
       

       if (rArcVersion.equals(rArcClientVersion)){
           Logger.getLogger(UpdateRequest.class.getName()).log(Level.INFO, "\tClientVersion ("+rArcClientVersion+") OK");
           response.setStatus(response.SC_OK);
        }
        else{
            Logger.getLogger(UpdateRequest.class.getName()).log(Level.INFO, "\tClientVersion ("+rArcClientVersion+") NOT OK...UPDATE");
            response.setStatus(response.SC_GONE);
        }
    }

    
}
